package org.research.struts.interceptor;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LoginedCheckInterceptor extends AbstractInterceptor {
	private static final long serialVersionUID = -3516350810639115489L;

	public String intercept(ActionInvocation ai) throws Exception {
		String url = ServletActionContext.getRequest().getRequestURL()
				.toString();
		///User admin = null;
		if (url.indexOf("admin_login.do") != -1
				|| url.indexOf("admin_logout.do") != -1) {
			return ai.invoke();
		} else {
			//admin = (User) ServletActionContext.getRequest().getSession().getAttribute("admin");
			//if (admin == null) {
				return "backdoLogin";
			//}else 
				//return ai.invoke();
			
		}
	}
}